package com.fdb.efp.nls.service.impl.yx;

import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;

import com.fdb.efp.nls.service.facade.NlsApplyInfoService;
import com.fdb.efp.nls.service.facade.ed.LimitControlsService;
import com.fdb.efp.nls.service.facade.queue.NlsProcessRuleService;
import com.fdb.efp.nls.service.facade.sx.NlsCreditInfoService;
import com.fdb.efp.nls.service.vo.NlsApplyInfoVO;
import com.fdb.efp.nls.service.vo.queue.NlsProcessBizVO;
import com.fdb.efp.nls.service.vo.queue.NlsProcessRuleVO;
import com.fdb.efp.nls.service.vo.sx.NlsCreditInfoVO;
import com.fdb.basic.framework.core.util.TimeUtil;
import com.fdb.efp.nls.service.facade.CustomerLimitInfoService;
import com.fdb.efp.esb.common.constant.InstitutionEnums;
import com.fdb.efp.limit.service.vo.LmtPrdContVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.fdb.basic.framework.core.exception.BizException;
import com.fdb.basic.framework.core.util.DateUtility;
import com.fdb.efp.nls.common.ConsoleConstant;
import com.fdb.efp.nls.common.IrAdjModeEnum;
import com.fdb.efp.nls.common.PrdStatEnums;
import com.fdb.efp.nls.common.RateTypeEnum;
import com.fdb.efp.nls.service.facade.PrdInfoService;
import com.fdb.efp.nls.service.facade.PrdSoltRuleService;
import com.fdb.efp.nls.service.vo.PrdInfoVO;
import com.fdb.efp.nls.service.vo.PrdSoltRuleVO;
import com.fdb.efp.nls.common.ContConstant;
import com.fdb.efp.nls.service.facade.CtrLoanContService;
import com.fdb.efp.nls.service.vo.CtrLoanContVO;
import com.fdb.efp.esb.common.constant.MsLoanConstant;
import com.fdb.efp.esb.common.constant.nls.NlsProdCdEnum;
import com.fdb.efp.esb.service.bo.req.yx.LetterBasicInfo;
import com.fdb.efp.esb.service.bo.req.yx.LetterExpanding;
import com.fdb.efp.esb.service.bo.req.yx.LetterMessage;
import com.fdb.efp.esb.service.bo.req.yx.LetterReq;
import com.fdb.efp.esb.service.bo.resp.yx.LetterResp;
import com.fdb.efp.esb.service.facade.yx.LetterService;
import com.fdb.efp.limit.service.facade.LmtPrdContService;
import com.fdb.efp.nls.service.facade.AccLoanService;
import com.fdb.efp.nls.service.vo.AccLoanVO;
import com.fdb.efp.nls.common.constant.PrdAdaptedSoltEnums;
import com.fdb.efp.nls.service.impl.SoltServiceImpl;
import com.fdb.efp.rule.common.enumeration.RefuseType;
import com.fdb.efp.rule.common.enumeration.Rule;
import com.fdb.efp.rule.service.facade.RuleCallService;
import com.fdb.efp.rule.service.vo.ReqAccessRuleVo;
import com.fdb.efp.rule.service.vo.ReqRuleVo;
import com.fdb.efp.rule.service.vo.RespRuleVO;


/**
 * 用信规则判断
 * 1.当前申请的渠道、产品、该客户是否存在有效状态的授信额度，可用额度是否大于申请额度
 * 2.该客户（证件类型、证件号码）是否在其他渠道、其他产品存在在途的支用申请（审批中，放款中）、未结清借据（未结清、逾期）
 *
 * @author heyingfeng
 * @version 1.0
 * @since 2019年3月15日 下午3:54:37
 */
@Service("letterRuleService")
public class LetterRuleServiceImpl extends SoltServiceImpl {

    private static final Logger log = LoggerFactory.getLogger(LetterRuleServiceImpl.class);
    private static final DateTimeFormatter timeStrFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
    private static final int MIN_TRM = 3;
    private static final int MAX_MYD_TRM = 12;
    private static final int MAX_ZXD_TRM = 36;

    @Override
    public void doExecute(NlsProcessBizVO nlsProcessBizVo, NlsApplyInfoVO nlsApplyInfoVO) throws Exception {
        String applySeq = nlsProcessBizVo.getApplySeq();
        String slotCode = nlsProcessBizVo.getSoltCode();
        boolean isAvailApply = false;
        boolean isCreditInvalid = false;
        boolean isDuring = false;
        BigDecimal applyAmt = nlsApplyInfoVO.getApplyAmt();//申请金额

        int num2 = 0;
        int num = 0;
        try {
            /** 产品校验 **/
            log.info("开始进行准入规则产品校验,流水号:" + applySeq);
            Objects.requireNonNull(nlsApplyInfoVO);

            String prdId = nlsApplyInfoVO.getPrdId();
            PrdInfoVO prdInfoVo = new PrdInfoVO();
            prdInfoVo.setPrdId(prdId);
            prdInfoVo = prdInfoService.queryByPk(prdInfoVo);

            // 判断产品生效失效逻辑
            PrdStatEnums prdStat = PrdStatEnums.parse(prdInfoVo.getPrdStatus());
            if (!Objects.equals(prdStat, PrdStatEnums.IN_USE)) {
                nlsProcessBizVo.setRefuseMsg(RefuseType.OTHER.getMsg());
                throw new BizException("产品： " + prdInfoVo.getPrdName() + " 不是有效状态");
            }
            /**额度管控 查询客户限额表 modify by chenxuan*/
            BigDecimal availAmt = limitControlsService.getAvailAmt(nlsApplyInfoVO);
            /**额度管控 授信有效性:单个客户单个产品必须只有一个有效授信 modify by chenxuan*/
            LmtPrdContVO lmtPrdContVo = new LmtPrdContVO();
            NlsCreditInfoVO nlsCreditInfoVo = new NlsCreditInfoVO();

            nlsCreditInfoVo.setBdTransactionId(nlsApplyInfoVO.getBdTransactionId());
            nlsCreditInfoVo = nlsCreditInfoService.queryByPk(nlsCreditInfoVo);
            if (nlsCreditInfoVo != null) {
                if (nlsCreditInfoVo.getLmtApplySeq() != null) {
                    lmtPrdContVo.setLmtStatus(ConsoleConstant.LIMIT_STS_02);//额度状态
                    lmtPrdContVo.setLmtApplySeq(nlsCreditInfoVo.getLmtApplySeq());
                    lmtPrdContVo = lmtPrdContService.queryByPk(lmtPrdContVo);
                    if (lmtPrdContVo != null) {
                        if (lmtPrdContVo.getLmtApplySeq() != null) {
                            // 额度生效
                            isAvailApply = true;
                            String invalidDate = lmtPrdContVo.getExpireDate();
                            int invalidflag = TimeUtil.compareDates(TimeUtil.getCurrentDate(), invalidDate);
                            // 比较额度有效期
                            if (invalidflag != -1) {
                                log.info(nlsApplyInfoVO.getApplySeq() + "授信协议已失效");
                                isCreditInvalid = true;
                            }
                        }
                    }
                }
            }
            /**额度管控 审批中贷款判断 modify by chenxuan*/
            isDuring = limitControlsService.isDuring(nlsApplyInfoVO);
            // TODO 查询个贷消费类信用贷款 是否在途

            // 用信期限
            if (NlsProdCdEnum.MYD.getValue().equals(prdInfoVo.getPrdCode())) {
                if (Integer.valueOf(nlsApplyInfoVO.getBdTerm()) < MIN_TRM || Integer.valueOf(nlsApplyInfoVO.getBdTerm()) > MAX_MYD_TRM) {// 贷款期限判断
                    nlsProcessBizVo.setRefuseMsg(RefuseType.OTHER.getMsg());
                    throw new BizException("期限： " + nlsApplyInfoVO.getBdTerm() + " 不是有效期限");
                }
            } else if (NlsProdCdEnum.ZXD.getValue().equals(prdInfoVo.getPrdCode())) {
                if (Integer.valueOf(nlsApplyInfoVO.getBdTerm()) < MIN_TRM || Integer.valueOf(nlsApplyInfoVO.getBdTerm()) > MAX_ZXD_TRM) {// 贷款期限判断
                    nlsProcessBizVo.setRefuseMsg(RefuseType.OTHER.getMsg());
                    throw new BizException("期限： " + nlsApplyInfoVO.getBdTerm() + " 不是有效期限");
                }
            }
            // 贷款金额
            BigDecimal maxAmt = prdInfoVo.getLoanAppMaxAmt();
            BigDecimal minAmt = prdInfoVo.getLoanAppMinAmt();

            // 判断该客户是否存在在途用信申请，是否存在未结清借据（包括逾期）
            AccLoanVO accLoanVO = new AccLoanVO();
            accLoanVO.setCertType(nlsApplyInfoVO.getCertType());
            accLoanVO.setCertCode(nlsApplyInfoVO.getCertCode());
            accLoanVO.setPrdId(prdId);
            BigDecimal totalAmt = BigDecimal.ZERO;
            // TODO 统计未结清状态  增加产品字段过滤
            if (NlsProdCdEnum.ZXD.getValue().equals(nlsApplyInfoVO.getPrdCode())) {
                List<AccLoanVO> accLoanVOs = Optional.ofNullable(accLoanService.queryAccLoanListByCondition(accLoanVO)).orElseGet(Collections::emptyList);
                totalAmt = accLoanVOs.stream().filter(vo -> {
                    String accStatus = vo.getAccountStatus();
                    return accStatus != null;
                }).map(AccLoanVO::getLoanBalance).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
            }
            /**【BdAccessRule011】用信申请准入规则_存在其他有效用信，迁移阶段实施口径：用客户的证件类型，证件号码搜索审批中的贷款申请(产品范围：网贷系统内产品)，如存在则拒绝新的申请
             * 【BdAccessRule014】用信申请准入规则_存在在途贷款申请，额度管控阶段实施口径：用客户的证件类型，证件号码搜索审批中、放款中的贷款申请(产品范围：所有个人消费类信用贷款)，如存在则拒绝新的申请
             *  额度管控 BdAccessRule011和BdAccessRule014规则有重复控制的地方，并且BdAccessRule011不符合额度管控阶段实施口径，故更新BdAccessRule011，不判断处理中贷款 modify by ludayong
             */
            // 根据审批状态分组
//            NlsApplyInfoVO nlsApplyCode = new NlsApplyInfoVO();
//            nlsApplyCode.setCertCode(nlsApplyInfoVO.getCertCode());
//            nlsApplyCode.setCertType(nlsApplyInfoVO.getCertType());
//
//            Map<String, List<NlsApplyInfoVO>> groupMap = Optional.ofNullable(nlsApplyInfoService.queryCertCode(nlsApplyCode))
//                    .orElseGet(Collections::emptyList).stream()
//                    .collect(Collectors.groupingBy(NlsApplyInfoVO::getNlsApplyState));
//            log.info("获取审批中的--申请金额");
//            // 获取审批中的--申请金额
//            totalAmt = Optional.ofNullable(groupMap.get(MsLoanConstant.NlsApplyStateEnum.APPR.VALUE)).orElseGet(ArrayList::new)
//                    .stream().filter(i -> !applySeq.equals(i.getApplySeq())).map(NlsApplyInfoVO::getApplyAmt).filter(Objects::nonNull)
//                    .reduce(totalAmt, BigDecimal::add);
//            log.info("获取审批通过,待放款--申请金额");
//            // 获取审批通过,待放款--申请金额
//            totalAmt = Optional.ofNullable(groupMap.get(MsLoanConstant.NlsApplyStateEnum.PASS.VALUE)).orElseGet(ArrayList::new)
//                    .stream().filter(i -> i.getDnSts() != null && i.getDnSts().equals(BaseConstant.DN_STS_3))
//                    .map(NlsApplyInfoVO::getApplyAmt).filter(Objects::nonNull)
//                    .reduce(totalAmt, BigDecimal::add);

            /** 初始化规则过程表 */
            NlsProcessRuleVO nlsProcessRuleVO = new NlsProcessRuleVO();
            nlsProcessRuleVO.setApplySeq(applySeq);
            nlsProcessRuleVO.setCreateTime(DateUtility.getCurrDateTime());
            nlsProcessRuleVO.setLastModifyTime(DateUtility.getCurrDateTime());
            nlsProcessRuleVO.setPrdCode(prdId);
            nlsProcessRuleVO.setPrdName(nlsApplyInfoVO.getPrdName());
            nlsProcessRuleVO.setCusName(nlsApplyInfoVO.getCusName());
            nlsProcessRuleVO.setCusId(nlsApplyInfoVO.getCusId());

            /** 添加要执行的规则 */
            List<PrdSoltRuleVO> prdSoltRules = prdSoltRuleService.queryByPrdIdAndSoltCode(prdId, slotCode);

            /** 执行规则 **/
            log.info("准入规则参数准备,流水号：" + applySeq + ",开始执行准入规则");
            ReqRuleVo reqRuleVo = new ReqRuleVo();
            reqRuleVo.setAppNo(applySeq);
            reqRuleVo.setPrdName(nlsApplyInfoVO.getPrdName());
            ReqAccessRuleVo param = new ReqAccessRuleVo();
            param.setMaxLoanAmt(maxAmt);// 贷款申请最大金额
            param.setMinLoanAmt(minAmt);// 贷款申请最小金额
            param.setLoanAmt(applyAmt);// 贷款申请金额
            param.setCusLoanBal(totalAmt);// 贷款余额
            param.setAvailAmt(availAmt); // 可用额度
            param.setAvailApply(isAvailApply);// 有效授信
            param.setDuring(isDuring);// 是否在途
            param.setCreditInvalid(isCreditInvalid); // 是否在授信有效期内
            reqRuleVo.setReqAccessRuleVo(param);

            /**批量执行规则**/
            List<RespRuleVO> list = ruleService.executeBatchRule(Rule.RuleType.BDACCESS, reqRuleVo);
            /**规则结果分组**/
            Map<String, List<RespRuleVO>> map = list.stream().collect(Collectors.groupingBy(RespRuleVO::getRuleId));
            /** 规则结果信息  反馈给开放平台*/
            String refuseMsg = "";
            String reasonCode = "";
            /** 规则结果信息  记录拒绝原因细类*/
            StringBuilder sb = new StringBuilder();
            for (int j = 0; j < prdSoltRules.size(); j++) {
                String order = prdSoltRules.get(j).getRuleOrder();
                /** 规则名称method映射 */
                Method methodRuleName = NlsProcessRuleVO.class.getMethod("setRuleName" + order, String.class);
                /** 规则状态method映射 */
                Method methodRuleState = NlsProcessRuleVO.class.getMethod("setRuleState" + order, String.class);
                /** 规则时间method映射 */
                Method methodRuleTime = NlsProcessRuleVO.class.getMethod("setRuleTime" + order, String.class);

                methodRuleName.invoke(nlsProcessRuleVO, prdSoltRules.get(j).getRuleCode());
                methodRuleTime.invoke(nlsProcessRuleVO, DateUtility.getCurrAppDateTimeString());
                if (map.get(prdSoltRules.get(j).getRuleCode()) != null) {
                    methodRuleState.invoke(nlsProcessRuleVO, PrdAdaptedSoltEnums.SoltProcessStateEnum.FAILURE.getCode());
                    sb.append(prdSoltRules.get(j).getRuleName()).append("规则不通过;");
                    /**根据规则id映射返回开放平台错误信息**/
                    reasonCode = MsLoanConstant.ReasonCodeMap.get(prdSoltRules.get(j).getRuleCode());
                    refuseMsg = MsLoanConstant.ReasonMsgMap.get(prdSoltRules.get(j).getRuleCode());
                    break;
                } else {
                    methodRuleState.invoke(nlsProcessRuleVO, PrdAdaptedSoltEnums.SoltProcessStateEnum.SUCCESS.getCode());
                }
            }
            /**设置百度原因说明**/
            nlsApplyInfoVO.setBdReasonCode(reasonCode);
            nlsApplyInfoVO.setBdReasonMsg(refuseMsg);
            /** 插入规则过程表 */
            nlsProcessRuleService.insertNlsProcessRule(nlsProcessRuleVO);

            if (!list.isEmpty()) {
                throw new BizException(sb.toString());
            }

            /** 插入贷款合同表 **/
            final CtrLoanContVO ctrLoanContVO = new CtrLoanContVO();
            ctrLoanContVO.setContNo(applySeq);//合同号
            ctrLoanContVO.setSerno(applySeq);
            ctrLoanContVO.setContType(ConsoleConstant.CONT_TYPE_02); // 合同类型 -- 借款合同
            ctrLoanContVO.setPrdCode(prdInfoVo.getPrdCode());
            ctrLoanContVO.setPrdId(prdInfoVo.getPrdId());
            ctrLoanContVO.setPrdName(prdInfoVo.getPrdName());
            ctrLoanContVO.setCusId(nlsApplyInfoVO.getCusId());
            ctrLoanContVO.setCusName(nlsApplyInfoVO.getCusName());
            ctrLoanContVO.setCertCode(nlsApplyInfoVO.getCertCode());
            ctrLoanContVO.setCertType(nlsApplyInfoVO.getCertType());
            ctrLoanContVO.setTermTimeType(nlsApplyInfoVO.getLoanTermType()); // 期限类型
            ctrLoanContVO.setLoanTerm(new BigDecimal(nlsApplyInfoVO.getBdTerm()));
            ctrLoanContVO.setApprovalAmt(nlsApplyInfoVO.getApplyAmt()); // 审批金额
            ctrLoanContVO.setContAmt(nlsApplyInfoVO.getApplyAmt()); // 合同金额
            ctrLoanContVO.setAvailAmt(BigDecimal.ZERO); // 合同可用金额
            ctrLoanContVO.setTotalIssueAmt(nlsApplyInfoVO.getApplyAmt()); // 累计发放金额
            ctrLoanContVO.setContState(ContConstant.CONT_STATUS_101); // 合同状态 - 待签订
            ctrLoanContVO.setContStartDt(nlsApplyInfoVO.getApplyDate());
            ctrLoanContVO.setContEndDt(LocalDate.now()
                    .plusMonths(Long.valueOf(nlsApplyInfoVO.getBdTerm()))
                    .format(DateTimeFormatter.ISO_LOCAL_DATE));
            ctrLoanContVO.setIntRateType(RateTypeEnum.NORMAL.getCode()); // 普通贷款
            ctrLoanContVO.setIrAdjustMode(IrAdjModeEnum.FIXED.getCode()); // 固定利率
            ctrLoanContVO.setUseDec(nlsApplyInfoVO.getLoanPurpose()); // 借款用途
            ctrLoanContVO.setChannelCode(nlsApplyInfoVO.getChannelNo());
            ctrLoanContVO.setLastUpdateUser("admin");
            ctrLoanContVO.setCreateUser("admin");
            ctrLoanContVO.setCreateTime(LocalDateTime.now().format(timeStrFormatter));
            ctrLoanContVO.setLastUpdateTime(LocalDateTime.now().format(timeStrFormatter));
            ctrLoanContVO.setLastUpdateUser("admin");
			// add by ludayong 2019/11/15 【数据权限】增加登记机构赋值
			// 登记机构
			ctrLoanContVO.setInputBrId(InstitutionEnums.InstitutionEnum.GZYHZHYHZXSCTD1.getCode());
            num2 = ctrLoanContService.insertCtrLoanCont(ctrLoanContVO);
            if (num2 == -1) {
                throw new BizException("生成合同信息失败！");
            }
            //更新放款状态
            nlsApplyInfoVO.setDnSts(MsLoanConstant.DN_STS_3);// 放款状态
            num = nlsApplyInfoService.updateByPk((nlsApplyInfoVO));
            if (num == -1) {
                throw new BizException("用信更新放款状态失败！");
            }
            /**额度管控，更新额度有效期*/
                this.invalidLimit(lmtPrdContVo,nlsCreditInfoVo);
            //回调接口
            this.letterBack(nlsApplyInfoVO);
        } catch (Exception e) {
            log.error(Arrays.toString(e.getStackTrace()));
            nlsProcessBizVo.setExceptionFlag(true);
            nlsProcessBizVo.setExceptionMsg(e);
        }
    }

    private void letterBack(NlsApplyInfoVO nlsApplyInfoVO) {
        try {
            //回调接口
            log.info("用信审核通知接口，流水号:" + nlsApplyInfoVO.getApplySeq());
            Objects.requireNonNull(nlsApplyInfoVO);// 网贷申请信息不能为空
            LetterReq letterReq = new LetterReq();
            LetterMessage letterMessage = new LetterMessage();
            LetterBasicInfo letterBasicInfo = new LetterBasicInfo();
            LetterExpanding letterExpanding = new LetterExpanding();
            letterReq.setProdCd(nlsApplyInfoVO.getPrdCode());//产品代码
            letterReq.setRqsFlg(nlsApplyInfoVO.getBdReqSn());//请求方需要保证永远唯一 响应方据此判断是否重复请求
            letterReq.setRetCd(MsLoanConstant.RetCodeEnum.SUCCESS.VALUE);
            letterReq.setTxnMd("async");//交易模式
            letterReq.setRepeatRqsBss(nlsApplyInfoVO.getBdReqSn());//重复请求依据
            /** Message	业务数据 start */
            letterMessage.setSessionId(nlsApplyInfoVO.getApplySeq());// 交易流水号
            letterMessage.setEvTp("transaction");//事务类型
            letterMessage.setEvID(nlsApplyInfoVO.getBdTransactionId());//事务ID
            letterMessage.setRqsTmstmp(new Date().getTime() + "");//时间戳
            /** BasicInfo	基本信息 start */
            letterBasicInfo.setIDCertNo(nlsApplyInfoVO.getCertCode());//身份证号
            letterBasicInfo.setBankCardNo(nlsApplyInfoVO.getRecvAcctNo());//银行卡号
            letterBasicInfo.setCustNm(nlsApplyInfoVO.getCusName());//客户姓名
            letterBasicInfo.setMblNo(nlsApplyInfoVO.getMobile());//手机号码
            /** BasicInfo	基本信息 end */
            /** Expanding	定制域 start */
            letterExpanding.setInstRsnCd(nlsApplyInfoVO.getBdReasonCode());    //机构原因码
            letterExpanding.setInstRsnCdRmk(nlsApplyInfoVO.getBdReasonMsg());    //机构原因码说明
            letterExpanding.setInstPolcyCd(MsLoanConstant.RisCodeEnum.SUCCESS.VALUE);    //机构策略码
            /** Expanding	定制域 end */
            letterMessage.setBasicInfo(letterBasicInfo);
            letterMessage.setExpanding(letterExpanding);
            letterReq.setMessage(letterMessage);
            LetterResp letterResp = letterService.letterNotify(letterReq);// 发送请求
            if (!MsLoanConstant.RetCodeEnum.SUCCESS.VALUE.equals(letterResp.getRetCd()) ||
                    !"E1001".equals(letterResp.getRetCd())) {// 0：请求成功，其他编码均代表失败
                log.error("调用用信审批结果消费接口返回信息出错");
            }
            log.error("调用用信审批结果消费接口返回信息成功");
        } catch (Exception e) {
            log.error("调用用信审批结果回调出现异常：" + e.getMessage());
        }
    }


    /**
     * 需求编号：【额度管控】
     * 问题编号：【用信成功后，满意贷额度到期日设置为“2099-12-31”，授信期限设置为“9999”】
     * 开发人员：【chenxuan】
     * 创建/修改日期：【2019/9/4】
     * 修改描述：
     *
     * @return void
     * @Param []
     **/
    public void invalidLimit(LmtPrdContVO lmtPrdContVo, NlsCreditInfoVO nlsCreditInfo) {
        if (lmtPrdContVo != null) {
            if (lmtPrdContVo.getLmtApplySeq() != null) {
                lmtPrdContVo.setExpireDate("2099-12-31");
                lmtPrdContVo.setTerm(new BigDecimal("9999"));
                lmtPrdContVo.setValidDays("9999");
                lmtPrdContService.updateByPk(lmtPrdContVo);
            }
        }
        if(nlsCreditInfo != null){
            if (nlsCreditInfo.getLmtApplySeq() != null) {
                nlsCreditInfo.setApplyTerm("9999");// 申请期限
                nlsCreditInfoService.updateByPk(nlsCreditInfo);
            }
        }

    }

    @Autowired
    @Qualifier("nlsApplyInfoService")
    private NlsApplyInfoService nlsApplyInfoService;
    @Autowired
    @Qualifier("nlsCreditInfoService")
    private NlsCreditInfoService nlsCreditInfoService;
    @Autowired
    @Qualifier("prdInfoService")
    private PrdInfoService prdInfoService;
    @Autowired
    @Qualifier("ruleCallService")
    private RuleCallService ruleService;
    @Autowired
    @Qualifier("ctrLoanContService")
    private CtrLoanContService ctrLoanContService;
    @Autowired
    @Qualifier("nlsProcessRuleService")
    private NlsProcessRuleService nlsProcessRuleService;
    @Autowired
    @Qualifier("prdSoltRuleService")
    private PrdSoltRuleService prdSoltRuleService;
    @Autowired
    @Qualifier("accLoanService")
    private AccLoanService accLoanService;
    @Autowired
    @Qualifier("lmtPrdContService")
    private LmtPrdContService lmtPrdContService;
    @Autowired
    @Qualifier("letterService")
    private LetterService letterService;// 用信贷款审核通知
    @Autowired
    @Qualifier("limitControlsService")
    private LimitControlsService limitControlsService;// 已占用额度
    @Autowired
    @Qualifier("customerLimitInfoService")
    private CustomerLimitInfoService customerLimitInfoService;
}
